<!DOCTYPE html>
<html lang="en">
  <head>
    <title>Data Extension Reference</title>
    <link rel="stylesheet" type="text/css" href="../css/jazzy.css" />
    <link rel="stylesheet" type="text/css" href="../css/highlight.css" />
    <meta charset='utf-8'>
    <script src="../js/jquery.min.js" defer></script>
    <script src="../js/jazzy.js" defer></script>
    
  </head>
  <body>
    <a name="//apple_ref/swift/Extension/Data" class="dashAnchor"></a>
    <a title="Data Extension Reference"></a>
    <header>
      <div class="content-wrapper">
        <p><a href="../index.html">CryptorECC Docs</a> (100% documented)</p>
      </div>
    </header>
    <div class="content-wrapper">
      <p id="breadcrumbs">
        <a href="../index.html">CryptorECC Reference</a>
        <img id="carat" src="../img/carat.png" />
        Data Extension Reference
      </p>
    </div>
    <div class="content-wrapper">
      <nav class="sidebar">
        <ul class="nav-groups">
          <li class="nav-group-name">
            <a href="../Classes.html">Classes</a>
            <ul class="nav-group-tasks">
              <li class="nav-group-task">
                <a href="../Classes/ECPrivateKey.html">ECPrivateKey</a>
              </li>
              <li class="nav-group-task">
                <a href="../Classes/ECPublicKey.html">ECPublicKey</a>
              </li>
            </ul>
          </li>
          <li class="nav-group-name">
            <a href="../Extensions.html">Extensions</a>
            <ul class="nav-group-tasks">
              <li class="nav-group-task">
                <a href="../Extensions/Data.html">Data</a>
              </li>
              <li class="nav-group-task">
                <a href="../Extensions/String.html">String</a>
              </li>
            </ul>
          </li>
          <li class="nav-group-name">
            <a href="../Structs.html">Structures</a>
            <ul class="nav-group-tasks">
              <li class="nav-group-task">
                <a href="../Structs/ECError.html">ECError</a>
              </li>
              <li class="nav-group-task">
                <a href="../Structs/ECSignature.html">ECSignature</a>
              </li>
              <li class="nav-group-task">
                <a href="../Structs/EllipticCurve.html">EllipticCurve</a>
              </li>
            </ul>
          </li>
        </ul>
      </nav>
      <article class="main-content">
        <section>
          <section class="section">
            <h1>Data</h1>
            <p>Extensions for encrypting, decrypting or signing <code>Data</code> using the appropriate algorithm determined by the key&rsquo;s curve with the provided <code><a href="../Classes/ECPrivateKey.html">ECPrivateKey</a></code> or <code><a href="../Classes/ECPublicKey.html">ECPublicKey</a></code>.</p>

          </section>
          <section class="section task-group-section">
            <div class="task-group">
              <ul>
                <li class="item">
                  <div>
                    <code>
                    <a name="/s:10Foundation4DataV10CryptorECCE7decrypt4withAcD12ECPrivateKeyC_tKF"></a>
                    <a name="//apple_ref/swift/Method/decrypt(with:)" class="dashAnchor"></a>
                    <a class="token" href="#/s:10Foundation4DataV10CryptorECCE7decrypt4withAcD12ECPrivateKeyC_tKF">decrypt(with:)</a>
                    </code>
                  </div>
                  <div class="height-container">
                    <div class="pointer-container"></div>
                    <section class="section">
                      <div class="pointer"></div>
                      <div class="abstract">
                        <p>Decrypt the encrypted data using the provided <code><a href="../Classes/ECPrivateKey.html">ECPrivateKey</a></code>.
The signing algorithm used is determined based on the private key&rsquo;s elliptic curve.</p>
<div class="aside aside-throws">
    <p class="aside-title">Throws</p>
    An ECError if the Encrypted data fails to be decrypted.

</div>

                      </div>
                      <div class="declaration">
                        <h4>Declaration</h4>
                        <div class="language">
                          <p class="aside-title">Swift</p>
                          <pre class="highlight swift"><code><span class="kd">public</span> <span class="kd">func</span> <span class="nf">decrypt</span><span class="p">(</span><span class="n">with</span> <span class="nv">key</span><span class="p">:</span> <span class="kt"><a href="../Classes/ECPrivateKey.html">ECPrivateKey</a></span><span class="p">)</span> <span class="k">throws</span> <span class="o">-&gt;</span> <span class="kt">Data</span></code></pre>

                        </div>
                      </div>
                      <div>
                        <h4>Parameters</h4>
                        <table class="graybox">
                          <tbody>
                            <tr>
                              <td>
                                <code>
                                <em>ecPrivateKey</em>
                                </code>
                              </td>
                              <td>
                                <div>
                                  <p>The elliptic curve private key.</p>
                                </div>
                              </td>
                            </tr>
                          </tbody>
                        </table>
                      </div>
                      <div>
                        <h4>Return Value</h4>
                        <p>The plaintext Data.</p>
                      </div>
                    </section>
                  </div>
                </li>
              </ul>
            </div>
            <div class="task-group">
              <ul>
                <li class="item">
                  <div>
                    <code>
                    <a name="/s:10Foundation4DataV10CryptorECCE7encrypt4withAcD11ECPublicKeyC_tKF"></a>
                    <a name="//apple_ref/swift/Method/encrypt(with:)" class="dashAnchor"></a>
                    <a class="token" href="#/s:10Foundation4DataV10CryptorECCE7encrypt4withAcD11ECPublicKeyC_tKF">encrypt(with:)</a>
                    </code>
                  </div>
                  <div class="height-container">
                    <div class="pointer-container"></div>
                    <section class="section">
                      <div class="pointer"></div>
                      <div class="abstract">
                        <p>Encrypt the data using the <code><a href="../Classes/ECPublicKey.html">ECPublicKey</a></code>.
This either uses the <code>SecKeyAlgorithm</code>: <code>eciesEncryptionStandardVariableIVX963SHA256AESGCM</code>,
or the equivalent OpenSSL implementation.</p>
<div class="aside aside-throws">
    <p class="aside-title">Throws</p>
    An ECError is the plaintext fails to be encrypted.

</div>

                      </div>
                      <div class="declaration">
                        <h4>Declaration</h4>
                        <div class="language">
                          <p class="aside-title">Swift</p>
                          <pre class="highlight swift"><code><span class="kd">public</span> <span class="kd">func</span> <span class="nf">encrypt</span><span class="p">(</span><span class="n">with</span> <span class="nv">key</span><span class="p">:</span> <span class="kt"><a href="../Classes/ECPublicKey.html">ECPublicKey</a></span><span class="p">)</span> <span class="k">throws</span> <span class="o">-&gt;</span> <span class="kt">Data</span></code></pre>

                        </div>
                      </div>
                      <div>
                        <h4>Parameters</h4>
                        <table class="graybox">
                          <tbody>
                            <tr>
                              <td>
                                <code>
                                <em>ecPrivateKey</em>
                                </code>
                              </td>
                              <td>
                                <div>
                                  <p>The elliptic curve private key.</p>
                                </div>
                              </td>
                            </tr>
                          </tbody>
                        </table>
                      </div>
                      <div>
                        <h4>Return Value</h4>
                        <p>The encrypted Data.</p>
                      </div>
                    </section>
                  </div>
                </li>
              </ul>
            </div>
            <div class="task-group">
              <ul>
                <li class="item">
                  <div>
                    <code>
                    <a name="/s:10Foundation4DataV10CryptorECCE4sign4withAD11ECSignatureVAD12ECPrivateKeyC_tKF"></a>
                    <a name="//apple_ref/swift/Method/sign(with:)" class="dashAnchor"></a>
                    <a class="token" href="#/s:10Foundation4DataV10CryptorECCE4sign4withAD11ECSignatureVAD12ECPrivateKeyC_tKF">sign(with:)</a>
                    </code>
                  </div>
                  <div class="height-container">
                    <div class="pointer-container"></div>
                    <section class="section">
                      <div class="pointer"></div>
                      <div class="abstract">
                        <p>Sign the plaintext data using the provided <code><a href="../Classes/ECPrivateKey.html">ECPrivateKey</a></code>.
The Data is signed using ECDSA with either SHA256, SHA384 or SHA512, depending on the key&rsquo;s curve.</p>
<div class="aside aside-throws">
    <p class="aside-title">Throws</p>
    An ECError if a valid signature is unable to be created.

</div>

                      </div>
                      <div class="declaration">
                        <h4>Declaration</h4>
                        <div class="language">
                          <p class="aside-title">Swift</p>
                          <pre class="highlight swift"><code><span class="kd">public</span> <span class="kd">func</span> <span class="nf">sign</span><span class="p">(</span><span class="n">with</span> <span class="nv">key</span><span class="p">:</span> <span class="kt"><a href="../Classes/ECPrivateKey.html">ECPrivateKey</a></span><span class="p">)</span> <span class="k">throws</span> <span class="o">-&gt;</span> <span class="kt"><a href="../Structs/ECSignature.html">ECSignature</a></span></code></pre>

                        </div>
                      </div>
                      <div>
                        <h4>Return Value</h4>
                        <p>An ECSignature on failure.</p>
                      </div>
                    </section>
                  </div>
                </li>
              </ul>
            </div>
          </section>
        </section>
        <section id="footer">
          <p>&copy; 2019 <a class="link" href="https://github.com/IBM-Swift/BlueECC" target="_blank" rel="external">IBM</a>. All rights reserved. (Last updated: 2019-03-12)</p>
          <p>Generated by <a class="link" href="https://github.com/realm/jazzy" target="_blank" rel="external">jazzy ♪♫ v0.9.1</a>, a <a class="link" href="http://realm.io" target="_blank" rel="external">Realm</a> project.</p>
        </section>
      </article>
    </div>
  </body>
</div>
</html>
